/**************************************************************************
	File		: tpa5050.c
	Author		: 
	Date		: 2018-8-18
***************************************************************************/
	
/**************************************************************************
    								include
***************************************************************************/
#include "i2c.h"
#include "tpa5050.h"
/**************************************************************************
    								macro
***************************************************************************/
#define CONTROL					1
#define RIGHT_DELAY				2
#define LEFT_DELAY				4
#define FRAME_DELAY				6
#define RJ_PACKET_LEN			7
#define COMPLETE_UPDATE			8


/**************************************************************************
    								typedef
***************************************************************************/
	
/**************************************************************************
    								variables
***************************************************************************/
	
/**************************************************************************
    								functions
***************************************************************************/
void TPA_Init(uint8_t slaveAddr)
{
	uint8_t value;

	value = 0x00;			/* both active , I2S */
	I2C_Write(slaveAddr, CONTROL, &value, 1);
}

void TPA_SetDelay(uint8_t slaveAddr, uint16_t delay)
{
	uint8_t value = 0x01;
	
	I2C_Write(slaveAddr, RIGHT_DELAY, (uint8_t*)&delay, 2);
	I2C_Write(slaveAddr, LEFT_DELAY, (uint8_t*)&delay, 2);
	I2C_Write(slaveAddr, COMPLETE_UPDATE, &value,1);
}

